<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 100px;
            height: 50px;
            background-color: green;
            transition: 0.3 all;
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <script>
         const w=document.querySelector('.box');
         console.log(w.style.width);
         let flag=true; //ture 长大 false 缩小
         let min=100,max=200;
         let cur=min;
        let loop=() => {
            // 变量 长大还是缩小？
            w.style.width=cur+'px';
            if(flag){ 
                cur++;
                if(cur>=max){
                    flag=false;
                }
            }
            else{
                cur--;
                if(cur<=min){
                    flag=true;
                }
            }
        } // 1 秒=1000ms requestAnimationFrame

        // setInterval js 里精度不够
        // 游戏 requestAnimationFrame

        (function animloop() {
        loop();
        requestAnimationFrame(animloop);
    })()
    
    </script>
</body>
</html>